import { getCommentList } from "@/api/api"

export default {
    components: {
    },
    data() {
        return {
            commentList: [],
            skip: 0,
            limit: 10,
            comment_loading: false,
            comment_finished: false,
        }
    },
    created() {
    },
    methods: {
        getCommentList() {
            let { uid:user_id, article_id, skip, limit } = this
            getCommentList({
                user_id,
                article_id,
                skip,
                limit,
            }).then(res => {
                console.log(res)
                // 加载
                if (res.code == 0) {
                    this.commentList.push(...res.data)

                    let len = this.commentList.length;

                    if (len >= res.count) {
                        this.comment_finished = true;
                    } else {
                        // 加载状态结束
                        this.comment_loading = false;
                        this.skip = len;
                    }
                } else {
                    this.$toast(res.msg)
                }
            })
        }
    },
}

